import _ from 'lodash'
import graph1 from '@/components/mxgraph/graphLayout.vue'
export default class Tab {

    constructor(options) {
        var errMsg, template;
        //file.name file.path file.siddhiJson file.mxJSON
        _.set(this, 'id', 0);
        _.set(this, 'title', _.get(options, 'title'));
        _.set(this, 'name', _.get(options, 'name'))
        _.set(this, 'siddhiJson', _.get(options, 'siddhiJson'));
        _.set(this, 'mxJson', _.get(options, 'mxJson'));
        _.set(this, 'state', _.get(options, 'state'));
        _.set(this, 'appData', _.get(options, 'appData'));
        _.set(this, 'component', graph1);
        this.closable = true
        this.description = ""
        this.isDirty = false
        this.options = options;
        this._isActive = false;
        this.isPlay = null
    }

    setActive = function (isActive) {
        if (_.isBoolean(isActive)) {
            this._isActive = isActive;
            if (isActive) {
                //this.$el.addClass(_.get(this.options, 'cssClass.tab_active'));
            } else {
                //this.$el.removeClass(_.get(this.options, 'cssClass.tab_active'));
            }
        }
    };
    isActive = function () {
        return this._isActive;
    };
    setHeader = function (header) {
        this._tabHeader = header;
    };
    getHeader = function () {
        return this._tabHeader;
    };
    getContentContainer = function () {
        return this.$el.get(0);
    };

    setParent = function (parentTabList) {
        this._parentTabList = parentTabList;
    };
    getTitle = function () {
        return _.isNil(this.title) ? "untitled" : this._title;
    };
    setTitle = function (title) {
        this.title = title;
    };
    setRunMode = function () {
        this._tabHeader.addClass(_.get(this.options, 'cssClass.run_state'));
    };
    setDebugMode = function () {
        this._tabHeader.addClass(_.get(this.options, 'cssClass.debug_state'));
    };
    setNonRunningMode = function () {
        var debugClass = _.get(this.options, 'cssClass.debug_state');
        if (this._tabHeader.hasClass(debugClass)) {
            this._tabHeader.removeClass(debugClass);
        }
        var runClass = _.get(this.options, 'cssClass.run_state');
        if (this._tabHeader.hasClass(runClass)) {
            this._tabHeader.removeClass(runClass);
        }
    }

}
